package com.huike.web.controller.report;


import com.huike.report.domain.vo.BusinessChangeVO;
import com.huike.report.domain.vo.IndexBaseInfoVO;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import com.huike.report.domain.vo.SaleStatisticVO;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 查询今日处理的的线索数量，商机数量，合同数量，成交的金额
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        IndexBaseInfoVO todayInfo = reportService.getTodayInfo();
        return new AjaxResult(200,"操作成功",todayInfo);
    }

    /**
     * 查询当前用户待跟进的 线索，商机，和待分配的线索和商机
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam String beginCreateTime ,String endCreateTime){
        IndexTodoInfoVO todoInfo = reportService.getTodoInfo(beginCreateTime,endCreateTime);
        return new AjaxResult(200,"操作成功",todoInfo);
    }

    /**
     * 商机转化龙虎榜接口 用戶名稱、部門名稱、轉化數量、轉化率
     * @param beginCreateTime
     * @param endCreateTime
     * @return BusinessChangeVO
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,@RequestParam("endCreateTime") String endCreateTime){
        List<BusinessChangeVO> businessChangeVOList = reportService.businessChangeStatistics(beginCreateTime,endCreateTime);
        return new AjaxResult(200,"操作成功",businessChangeVOList);
    }

    /**
     * 线索转化龙虎榜接口 用戶名稱、部門名稱、轉化條數、轉化率
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam("beginCreateTime") String beginCreateTime,@RequestParam("endCreateTime") String endCreateTime){
        List<SaleStatisticVO> salesStatisticList = reportService.salesStatistic(beginCreateTime,endCreateTime);
        return new AjaxResult(200,"操作成功",salesStatisticList);
    }
}